package com.zlj.springcloud.service;

import com.zlj.springcloud.entity.Dept;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description: java类作用描述
 * @Author: zlj
 * @CreateDate: 2018/6/25 13:48
 * @Version: 1.0.0
 */
@Component
public class DeptClientServiceFallbackFactory implements FallbackFactory<DeptClientService> {

    @Override
    public DeptClientService create(Throwable throwable) {
        return new DeptClientService() {

            @Override
            public boolean add(Dept dept) {
                return false;
            }

            @Override
            public Dept get(Long id) {
                return new Dept().setDeptno(id).setDb_source("no this database in MySQL").
                        setDname("该ID: " + id + "没有对应信息，Consumer客户端提供的降级信息，此刻服务Provider已经关闭");
            }

            @Override
            public List<Dept> list() {
                return null;
            }
        };
    }
}
